#include <bits/stdc++.h>
using namespace std;
bool prost(long long a){
    long long k = 0;
    for (int i = 1;i<=a;i++){
        if (a%i==0){
            k+=1;
        }
    }
    if (k!=2){
        return true;
    }
    else{
        return false;
    }
}
int main()
{
    string s,s2="";
    long long s1=0,a=0,b=0,l=0,r=1;
    getline(cin,s);
    s+=" ";
    vector <string> mas;
    for (int i = 0;i<s.size();i++){
        if (s[i]==' '){
            for (int j = l;j<i;j++){
                s2+=s[j];
            }
            mas.push_back(s2);
            l=i+1;
            s2="";
        }
    }
    for (int i = 0;i<mas.size();i++){
        if (mas[i]=="zero"){
            s1+=0;
            s1*=10;
        }
        if (mas[i]=="one"){
            s1+=1;
            s1*=10;
        }
        if (mas[i]=="two"){
            s1+=2;
            s1*=10;
        }
        if (mas[i]=="three"){
            s1+=3;
            s1*=10;
        }
        if (mas[i]=="four"){
            s1+=4;
            s1*=10;
        }
        if (mas[i]=="five"){
            s1+=5;
            s1*=10;
        }
        if (mas[i]=="six"){
            s1+=6;
            s1*=10;
        }
        if (mas[i]=="seven"){
            s1+=7;
            s1*=10;
        }
        if (mas[i]=="eight"){
            s1+=8;
            s1*=10;
        }
        if (mas[i]=="nine"){
            s1+=9;
            s1*=10;
        }
    }
    s1/=10;
    a=s1;
    b=s1;
    while(prost(a) and prost(b)){
        a++;
        b--;
    }
    if (s1<100 or s1>999){
        cout << "Wrong input";
    }
    else{
        if (not(prost(a)) and not(prost(b)) and a-s1==s1-b){
            cout << b;
        }
        else if (not(prost(a)) and prost(b)){
            cout << a;
        }
        else if (not(prost(b)) and prost(a)){
            cout << b;
        }
        else{
            cout << b;
        }
    }
    return 0;
}